﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CarLoanSystemWeb.MasterPage;
using CarLoanSystem.Comman;

namespace CarLoanSystemWeb.Page.Register
{
    public partial class RegisterMemberPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            wuc_register_member1.InfoMessege += new EventHandler(Call_InfoMessage);
            wuc_register_member1.ErrorMessege += new EventHandler(Call_ErrorMessage);
            wuc_register_member1.ErrorMessegeName += new EventHandler(Call_ErrorMessageName);
            wuc_register_member1.InfoMessegeUserName += new EventHandler(Call_InfoMessageUserName);
            wuc_register_member1.ErrorMessegeUserName += new EventHandler(Call_ErrorMessegeUserName);
        }

        private void Call_InfoMessage(object sender, EventArgs e)
        {
            InfoMessage("เพิ่มข้อมูลเรียบร้อยแล้ว");
            Response.AppendHeader("Refresh", "2; url=../../pageSignOn/SignOn.aspx");
        }

        private void Call_InfoMessageUserName(object sender, EventArgs e)
        {
            AjaxScript.AlertMsg("ชื่อผู้ใช้งานนี้สามารถใช้ได้", this);
        }

        private void Call_ErrorMessegeUserName(object sender, EventArgs e)
        {
            AjaxScript.AlertMsg("กรุณาตรวจสอบชื่อผู้ใช้งาน", this);
        }

        private void Call_ErrorMessage(object sender, EventArgs e)
        {
            ErrorMessage(sender.ToString());
        }

        private void Call_ErrorMessageName(object sender, EventArgs e)
        {
            ErrorMessage("ชื่อผู้ใช้งานนี้มีในระบบแล้ว");
        }

        private void InfoMessage(string msg)
        {
            ((RegisterMasterPage)this.Master).ShowInfoMessage(msg);
        }

        private void ErrorMessage(string msg)
        {
           ((RegisterMasterPage)this.Master).ShowErrorMessage(msg);
        }
    }
}